package com.dcbeida.activity.addnewpatient;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dcbeida.R;
import com.dcbeida.activity.BaseActivity;

import butterknife.Bind;
import butterknife.OnClick;

/**
 * 新增患者
 * Created by swt on 2017/9/5.
 */

public class SexAct extends BaseActivity {
    @Bind(R.id.img_back)
    ImageView imgBack;
    @Bind(R.id.tv_title)
    TextView tvTitle;
    @Bind(R.id.tv_nan)
    TextView tvNan;
    @Bind(R.id.tv_nv)
    TextView tvNv;
    @Bind(R.id.tv_zx)
    TextView tvZx;


    @Override
    protected int getLayoutResId() {
        return R.layout.choose_sex;
    }

    @Override
    public void setData() {
        Bundle bundle = getIntent().getExtras();
        if (null != bundle) {
            String sex = bundle.getString("sex");
            if (getString(R.string.nan).equals(sex)) {
                tvNan.setTextColor(getResources().getColor(R.color.c_0C87EA));
            } else if (getString(R.string.nv).equals(sex)) {
                tvNv.setTextColor(getResources().getColor(R.color.c_0C87EA));
            } else if (getString(R.string.zx).equals(sex)) {
                tvZx.setTextColor(getResources().getColor(R.color.c_0C87EA));
            }
            if (bundle.containsKey("other")) {
                tvZx.setVisibility(View.GONE);
            }
        }
    }


    @OnClick({R.id.img_back, R.id.tv_nan, R.id.tv_nv, R.id.tv_zx})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.img_back:
                finish();
                break;
            case R.id.tv_nan:
                setResult(getString(R.string.nan));
                break;
            case R.id.tv_nv:
                setResult(getString(R.string.nv));
                break;
            case R.id.tv_zx:
                setResult(getString(R.string.zx));
                break;
        }
    }

    private void setResult(String sex) {
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putString("sex", sex);
        intent.putExtras(bundle);
        setResult(RESULT_OK, intent);
        finish();
    }
}
